SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE FUNCTION dbo.[DnnProduct_GetProfileFieldSql]
(
	@PortalID int,
	@TemplateSql nvarchar(max)
)
RETURNS nvarchar(max)
AS
	BEGIN
		DECLARE @sql nvarchar(max)
		SELECT @sql = COALESCE(@sql + ',','') + '[' + PropertyName + ']' + @TemplateSql
		FROM DnnProduct_ProfilePropertyDefinition 
		WHERE PortalID = @PortalID 
			AND Deleted = 0
		RETURN(@sql) 
	END
GO
